﻿//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using GameFramework;
using System;
using UnityEngine.UI;

namespace Adventure
{
    /// <summary>
    /// 对话框显示数据。
    /// </summary>
    public class TipForm: UGuiForm
    {  
        private Text contentText;
        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);

            contentText = transform.FindTransform<Text>("TipText");

            //传递元组 Tuple
            //使用元组（Tuple）来携带两个参数。


            var tuple = userData as Tuple <string ,int>;
           
            contentText.text = tuple.Item1;

            switch (tuple.Item2)
            {
                case 1:                   
                    contentText.color = new UnityEngine.Color(1, 0, 0, 1);

                    break;
                case 2:
                    contentText.color = new UnityEngine.Color(0, 1, 0, 1);

                    break;
                case 3:
                    contentText.color = new UnityEngine.Color(0, 0, 1, 1);

                    break;
                default:
                    break;
            }
        }
    }
}
